import router from "./router";
import { getToken } from "@/utils/Auth"
import store from "./store";

router.beforeEach((to, from, next) => {
    const token = getToken();
    console.log(to)
    if (token) {
        if (to.path != "/login") {
            store.commit("brand/set_brandRoute", "")
            next()
        } else {
            next({ path: `/dashbord?rand=${Math.random()}` })
        }
    } else {
        if (to.path != "/login") {
            next({ path: "/login" })
        }
    }
    next()
})
